﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace HFController
{
    public class ControllerBase
    {
        public ControllerBase() { }

        /// <summary>
        /// 得到当前CityID
        /// </summary>
        /// <returns></returns>
        protected int getNowCityID()
        {
            if (HttpContext.Current.Session["city"] == null)
            {
                return 1;
            }
            return int.Parse(HttpContext.Current.Session["city"].ToString());
        }

        /// <summary>
        /// 私有方法，处理结果
        /// </summary>
        /// <param name="result"></param>
        protected void doResult(HFModel.ResultModel result)
        {
            HttpContext.Current.Response.Write("<script>alert('" + result.Message + "');" + result.goUrl + "</script>");
        }
        
        /// <summary>
        /// 得到登录的管理员的信息
        /// </summary>
        /// <returns></returns>
        protected hf.Model.admin getLoginAdminInfo()
        {
            hf.Model.admin adminModel = null;

            if (HttpContext.Current.Session["Admin"] != null)
            {
                adminModel = (hf.Model.admin)HttpContext.Current.Session["Admin"];
            }
            return adminModel;
        }
       
        /// <summary>
        /// 得到验证码
        /// </summary>
        /// <returns></returns>
        protected string geCheckCookiesNum()
        {
            if (HttpContext.Current.Session["CheckCode"] != null)
            {
                return HttpContext.Current.Session["CheckCode"].ToString();
            }
            else {
                return string.Empty;
            }
        }
    }
}
